/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-02-22 17:04:39
 */
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { getMap } from '@/utils/tools'
import Layout from '@/layout'
import { UserRouter } from './modules/user';
import { systemRouter } from './modules/system';
import { OperationRecordRouter } from './modules/operation-record';
import { permissionRouter } from './modules/permission';
import { moviesRouter } from './modules/movies';

export const routes: Array<RouteRecordRaw> = [
	{
		path: '/',
		redirect: '/index',
		component: Layout,
		name: 'index',
		meta: {
			title: '首页',
			alwaysShow: true,
		},
		children: [
			{
				path: '/index',
				component: () => import('@/components/home'),
				meta: { title: '首页', alwaysShow: true },
				name: 'Home',
			},
		],
	},
	{
		path: '/login',
		component: () => import('@/views/login/login.vue'),
		name: 'login',
		meta: {
			title: '登录',
			alwaysShow: true,
		},
	},
	{
		path: '/404',
		component: () => import('/src/errorPages/404.vue'),
		meta: { title: '404', alwaysShow: true },
		name: 'NotFind',
	},
]
// 实例化路由
const router = createRouter({
	history: createWebHistory('/'),
	routes: routes,
})
export default router
const routerList = [moviesRouter, UserRouter, OperationRecordRouter, permissionRouter, systemRouter]
const mapList = routerList.map((item) => getMap(item))
const mapGenerator = Object.assign({}, ...mapList)
export const asyncRouterMap: any = mapGenerator
